package androidsdklearn.activitylifecycle;

import androidsdklearn.activitylifecycle.R;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.Menu;

public class ActivityLifeCycleDemo extends Activity {

    private static final String TAG = ActivityLifeCycleDemo.class
            .getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d(TAG, "onCreate(" + savedInstanceState + ")");
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.d(TAG, "onStart()");
        logStoragePaths();
    }

    private void logStoragePaths() {
        Log.d(TAG, "Environment.getExternalStorageDirectory() "
                + Environment.getExternalStorageDirectory().getAbsolutePath());
        Log.d(TAG,
                "Environment.getExternalStoragePublicDirectory("
                        + Environment.DIRECTORY_MOVIES
                        + ") "
                        + Environment
                                .getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES));
        Log.d(TAG, "getPackageCodePath() " + getPackageCodePath());
        Log.d(TAG, "getApplicationInfo().sourceDir "
                + getApplicationInfo().sourceDir);
        Log.d(TAG, "getCacheDir() " + getCacheDir().getAbsolutePath());
        Log.d(TAG, "getFilesDir() " + getFilesDir().getAbsolutePath());
        Log.d(TAG,
                "getDir(testDir, MODE_PRIVATE) "
                        + getDir("testDir", Context.MODE_PRIVATE)
                                .getAbsolutePath());
        Log.d(TAG, "getDatabasePath(test.db) "
                + getDatabasePath("test.db").getAbsolutePath());
        Log.d(TAG, "getExternalCacheDir() "
                + getExternalCacheDir().getAbsolutePath());
        Log.d(TAG, "getExternalFilesDir(null)"
                + getExternalFilesDir(null).getAbsolutePath());
        Log.d(TAG, "getExternalFilesDir(" + Environment.DIRECTORY_MOVIES + ") "
                + getExternalFilesDir(Environment.DIRECTORY_MOVIES));
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        Log.d(TAG, "onRestoreInstanceState(" + savedInstanceState + ")");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.d(TAG, "onResume()");
    }

    public void onPause() {
        super.onPause();
        Log.d(TAG, "onPause()");
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.d(TAG, "onSaveInstanceState()");
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.d(TAG, "onStop()");
    }

    @Override
    public void onRestart() {
        super.onRestart();
        Log.d(TAG, "onRestart()");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy()");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_life_cycle_demo, menu);
        return true;
    }
}
